<?php 
namespace Admin\Controller;
use Think\Controller;

class MemberlevelController extends Controller
{
     public function lst(){
     	$model = D('MemberLevel');
     	$data = $model->select();

     	$count = $model->count();
     	$this->assign(array(
     			'data' => $data,
     			'count' => $count,

     			
     	));
     	$this->display();
     	
     }
	 public function add(){
	 	if(IS_POST)
	 	{
	 		$model = D('MemberLevel');
	 		if($model->create(I('post.'), 1))
	 		{
	 			if($model->add())
	 			{
	 				$this->success('添加成功！', U('lst'));
	 				exit;
	 			}
	 		}
	 		$this->error($model->getError());
	 	}
	 
	 	// 设置页面中的信息
	 
	 	$this->display();
	 }
	 //修改
	 public function edit()
	 {
	 	$id = I('get.id');
	 	if(IS_POST)
	 	{
	 		$model = D('MemberLevel');
	 		if($model->create(I('post.'), 2))
	 		{
	 			//var_dump(I('post.'));die();
	 			if($model->save() !== FALSE)
	 			{
	 				$this->success('修改成功！', U('lst'));
	 				exit;
	 			}
	 		}
	 		$this->error($model->getError());
	 	}
	 	$model = M('MemberLevel');
	 	$data = $model->find($id);
	 	$this->assign('data', $data);
	    
	 	
	 	$this->display();
	 }
	

}

